#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<deque>
using namespace std;
const int N = 1e6 + 10;
int a[N];
int n, m;

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    deque<int> as;
    for (int i = 1; i <= n; i++)
    {
        while (as.size() && a[as.back()] >= a[i])
        {
            as.pop_back();
        }
        as.push_back(i);
        if (as.back() - as.front() + 1 > m)
        {
            as.pop_front();
        }
        if (i >= m)
            cout << a[as.front()] << endl;
    }
    return 0;
}